<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    /* 父元素 */
    .container {
      width: 400px;
      height: 300px;
      margin: 0 auto;
      background-color: lemonchiffon;
      /* 容器属性-设置给父元素 */
      /* 开启弹性盒布局 
      弹性元素沿着主轴方向排列
      */
      display: flex;
    }

    /* 子元素 */
    .container div {
      width: 60px;
      height: 50px;
      color: white;
    }

    .div1 {
      flex-grow: 1;
    }



    .div3 {
      /* flex-grow 默认0 容器在有剩余空间的情况默认不会被占据 */
      /* 将剩余的一份空间给到div3 */
      flex-grow: 1;
    }
  </style>
</head>

<body>
  <div class="container">
    <div class="div1" style="background-color:red;">弹性元素1</div>
    <div class="div2" style="background-color:blue;">弹性元素2</div>
    <div class="div3" style="background-color:green;">弹性元素3</div>
  </div>

</body>

</html>